package com.corpgovernment.common.base;

import com.ctrip.corp.obt.generic.utils.StringUtils;

public class BaseService {

	/**
	 * 部门信息
	 */
	private static final ThreadLocal<StringBuilder> logBuilder = ThreadLocal.withInitial(StringBuilder::new);


	protected void initElkLog() {
		logBuilder.get();
	}

	/**
	 * 获取elkinfo日志
	 *
	 * @return
	 */
	protected String getElkInfoLog() {
		return logBuilder.get().toString();
	}


	protected void clearElkLog() {
		logBuilder.remove();
	}

	/**
	 * 增加elkinfo日志
	 *
	 * @param msg
	 * @param args
	 */
	protected void addElkInfoLog(String msg, Object... args) {
		if (StringUtils.isEmpty(msg)) {
			return;
		}
		if (args == null || args.length <= 0) {
			logBuilder.get().append(msg);
		} else {
			logBuilder.get().append(String.format(msg, args));
		}
		logBuilder.get().append(System.lineSeparator()).append(System.lineSeparator());
	}

}
